let data = [
    {
        "name": "1-1",
        "kind": "oo",
        "children": [
            {
                "name": "2-2",
                "kind": "ii",
            },
            {
                "name": "3-3",
                "children": [
                    {
                        "name": "4-4",
                        "children": [
                            {
                                "name": '707'
                            }
                        ]
                    }
                ]
            }
        ]
    },
    {
        "name": "5-5",
    },
    {
        "name": "6-6"
    }
]
function getName(data, key = 'name') {
    const result = []
    const dfs = (node) => {
        for (const p of node) {
            p.name && result.push(p[key])
            p.children && dfs(p.children)
        }
    }
    Array.isArray(data) && dfs(data)
    return result
}

console.log(getName(data));
